﻿/*----------------------------------------------------------------
// Copyright (C) 2014 苏州麦迪斯顿医疗科技股份有限公司
// 文件名：ConnectionMonitorFactory.cs
// 文件功能描述：ConnectionMonitorFactory
// 创建标识：顾伟伟-2014-04-03
----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CPOE.Framework.Throttling;
using System.Net.NetworkInformation;

namespace CPOE.Framework
{
    /// <summary>
    /// 一个从配制文件中，读取网络服务器地址表，创建网络连接监视器的静态工厂
    /// </summary>
    public abstract class ConnectionMonitorFactory
    {
        /// <summary>
        /// 从配制中读取服务器地址表，创建连接监视器
        /// </summary>
        /// <returns></returns>
        public static ConnectionMonitor Create()
        {
            var  connectons=new List<Connection>();

            //创建网卡连接监视器
            connectons.Add(new NetworkAdapterConnection());
           
            //从地址表中读取网络服务器地址
            foreach(var address in NetworkAddressTable.NetworkAddresses)
            {
               connectons.Add(new NetworkAddressConnection(address));
            }
           
            return new ConnectionMonitor(connectons);
        }
    }
}
